//导入axios实例
import { instance } from "@/request"
// 封装http请求
class Http {
  static BASE_URL = "http://api.tianditu.gov.cn"

  static getHttp(url) {
    return new Promise((resolve, reject) => {
      instance.get(this.BASE_URL + url).then((res) => {
        resolve(res)
      })
    })
  }
  //查询地点
  // static getTargetPlace(content) {
  //   return this.getHttp(
  //     `/v2/search?postStr={"keyWord":"${content}","level":12,"mapBound":"74,4,135,53","queryType":1,"start":0,"count":1000}&type=query&tk=85d34ed96468ba7ee66806d69f0ac8cd `
  //   )
  // }
  static getTargetPlace(content) {
    return this.getHttp(
      `/search?postStr={"keyWord":"${content}","level":"15","mapBound":"116.40569,39.91088,116.45119,39.93542","queryType":"7","count":"20","start":"0","queryTerminal":"10000"}&type=query&tk=85d34ed96468ba7ee66806d69f0ac8cd `
    )
  }
  //根据地名查经纬度
  static getLnalat(content) {
    return this.getHttp(
      `/geocoder?ds={"keyWord":"${content}"}&tk=85d34ed96468ba7ee66806d69f0ac8cd `
    )
  }
}

export { Http }
